<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>设置用户角色</title>
    <link type="text/css" rel="stylesheet" th:href="@{${skinPath} + '/css.css'}"/>
    <script type="text/javascript" src="../../inc/common.js"></script>
    <script src="../../js/jquery-1.9.1.min.js"></script>
    <script src="../../js/jquery-migrate-1.2.1.min.js"></script>
    <script src="../../js/jquery-alerts/jquery.alerts.js" type="text/javascript"></script>
    <script src="../../js/jquery-alerts/cws.alerts.js" type="text/javascript"></script>
    <link href="../../js/jquery-alerts/jquery.alerts.css" rel="stylesheet" type="text/css" media="screen"/>
    <link rel="stylesheet" href="../../js/bootstrap/css/bootstrap.min.css"/>
    <script src="../../js/bootstrap/js/bootstrap.min.js"></script>
    <link href="../../js/jquery-showLoading/showLoading.css" rel="stylesheet" media="screen"/>
    <script type="text/javascript" src="../../js/jquery-showLoading/jquery.showLoading.js"></script>
</head>
<body>
<div th:replace="th/include/tab_user :: navUser(${userName}, 2)"></div>
<div class="spacerH"></div>
<div th:inline="text" style="margin: 10px 0px; text-align: center">[[${realName}]] 的角色</div>
<form id="formRole" name="formRole" method="post" action="user_op.jsp?op=setuserofrole" onsubmit="return false">
    <table class="tabStyle_1 percent60" cellspacing="0" cellpadding="3" align="center">
        <tbody>
        <tr>
            <td align="left" nowrap class="tabStyle_1_title">设置角色</td>
        </tr>
        <tr>
            <td align="center" style="padding: 0px">
                <textarea style="width:100%; border: 0px" id="roleDescs" name="roleDescs" cols="40" rows="3" th:inline="text">[[${descs}]]</textarea>
                <input id="roleCodes" name="roleCodes" th:value="${roleCodes}" type="hidden"/>
            </td>
        </tr>
        <tr align="center">
            <td align="left" style="padding-top:5px" th:inline="text">
                <div>所属用户组的角色：[[${groupRoleDesc}]]</div>
                <div>注：用户默认属于“全部用户”角色</div>
            </td>
        </tr>
        </tbody>
    </table>
    <div style="text-align: center;margin-top: 10px">
        <input type=hidden name="userName" th:value="${userName}"/>
        <button id="btnSelect" class="btn btn-default">选择</button>
        &nbsp;&nbsp;&nbsp;&nbsp;
        <button id="btnOk" class="btn btn-default">确定</button>
    </div>
</form>
<br>
</body>
<script language="javascript" th:inline="javascript">
    $(function() {
        $('#btnSelect').click(function() {
            openWin("../../roleMultilSelBack.do?roleCodes=" + [[${roleCodes}]] + "&unitCode=" + [[${unitCode}]], 800, 600);
        })

        $('#btnOk').click(function() {
            $.ajax({
                type: "post",
                url: "../../user/setRoleOfUser.do",
                data: $('#formRole').serialize(),
                dataType: "json",
                beforeSend: function(XMLHttpRequest) {
                    $('body').showLoading();
                },
                success: function(data, status){
                    jAlert(data.msg, "提示");
                },
                complete: function(XMLHttpRequest, status){
                    $('body').hideLoading();
                },
                error: function(){
                    //请求出错处理
                    alert(XMLHttpRequest.responseText);
                }
            });
        })
    })

    function getUserRoles() {
        return $('#userRoles').val();
    }

    function setRoles(roles, descs) {
        $('#roleCodes').val(roles);
        $('#roleDescs').val(descs);
    }
</script>
</html>